package com.sh1604.duitang.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sh1604.duitang.R;
import com.sh1604.duitang.mybean.ImageBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * ***********************************************************
 * author: jie
 * time: 2016/7/22 19:40
 * name:
 * overview:Build.VERSION.SDK_INT:版本号
 * usage:
 * *************************************************************
 */
public class MyDataAdapter extends RecyclerView.Adapter<MyDataAdapter.MyHolder>{

    private Context mContext;
    private List<ImageBean.DataBean.GroupItemsBean> mDatas;

    public MyDataAdapter(Context context,List<ImageBean.DataBean.GroupItemsBean> datas){
        this.mContext = context;
        this.mDatas = datas;
    }
    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_recy, parent, false);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        ImageBean.DataBean.GroupItemsBean bean = mDatas.get(position);
        holder.item_tv1.setText(bean.getName());
        Picasso.with(mContext).load(bean.getIcon_url()).into(holder.item_iv1);
    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    class MyHolder extends RecyclerView.ViewHolder{
        private TextView item_tv1;
        private ImageView item_iv1;
        public MyHolder(View itemView) {
            super(itemView);
            item_iv1 = (ImageView) itemView.findViewById(R.id.item_iv1);
            item_tv1 = (TextView) itemView.findViewById(R.id.item_tv1);
        }
    }
}
